<?php
class DomArOneToManyListener extends DomArObject {
	
	/**
	 * @orm has many DomArOneToManyListener inverse parent setValidator()
	 * @orm listener beforeAdd beforeAdd(3)
	 * @orm listener afterAdd afterAdd(4)
	 * @orm listener beforeRemove beforeRemove(5)
	 * @orm listener afterRemove afterRemove(6)
	 */
	public $items;
	
	/**
	 * @orm has parent DomArOneToManyListener inverse items
	 * @orm listener beforeSet beforeSet(1)
	 * @orm listener afterSet afterSet(2)
	 * @orm validator method validator()
	 */
	public $parent;
	
	public $beforeAdd;
	public $afterAdd;
	public $beforeRemove;
	public $afterRemove;
	public $beforeSet;
	public $afterSet;
	
	public $setValidator;
	public $validator;
	
	public $beforeAddCount;
	public $afterAddCount;
	public $beforeRemoveCount;
	public $afterRemoveCount;
	public $beforeSetCount;
	public $afterSetCount;
	
	public $setValidatorCount;
	public $validatorCount;
	
	public function reset() {
		$this->beforeAdd = 1;
		$this->afterAdd = 1;
		$this->beforeRemove = 1;
		$this->afterRemove = 1;
		$this->beforeSet = 1;
		$this->afterSet = 1;
		
		$this->setValidator = 1;
		$this->validator = 1;
		
		$this->beforeAddCount = 0;
		$this->afterAddCount = 0;
		$this->beforeRemoveCount = 0;
		$this->afterRemoveCount = 0;
		$this->beforeSetCount = 0;
		$this->afterSetCount = 0;
		
		$this->setValidatorCount = 0;
		$this->validatorCount = 0;
	}
	
	public function beforeAdd( $value, $arg ) {
		$this->beforeAdd = $arg == 3 ? 0 : 2; 
		$this->beforeAddCount++;
	}
	
	public function afterAdd( $value, $arg ) {
		$this->afterAdd = $arg == 4 ? 0 : 2; 
		$this->afterAddCount++;
	}
	
	public function beforeRemove( $value, $arg ) {
		$this->beforeRemove = $arg == 5 ? 0 : 2; 
		$this->beforeRemoveCount++;
	}
	
	public function afterRemove( $value, $arg ) {
		$this->afterRemove = $arg == 6 ? 0 : 2; 
		$this->afterRemoveCount++;
	}
	
	public function beforeSet( $value, $arg ) {
		$this->beforeSet = $arg == 1 ? 0 : 2;
		$this->beforeSetCount++;
	}
	
	public function afterSet( $arg ) {
		$this->afterSet = $arg == 2 ? 0 : 2;
		$this->afterSetCount++;
	}
	
	public function setValidator( $b ) {
		//debug(exceptionToString(new Exception()));
		$this->setValidator = 0;
		$this->setValidatorCount++;
		return 0;
	}
	
	public function validator( $b ) {
		$this->validator = 0;
		$this->validatorCount++;
		return 0;
	}
	
}
?>